import { useState,useEffect } from "react";
export default function useDebounce(value:any,delay:number){
    const [newValue, setNewValue] = useState(value);

    useEffect(()=>{
     const timeId = setTimeout(
        ()=>{
             setNewValue(value)
         }, delay
     )

        return ()=>{
            clearTimeout(timeId)
        }
    },[value,delay])


    return newValue
}